$(document).ready(function(){
	$('#backup_btn').bind('click',backup);
	getBackup();
})

function getBackup(){
	$.post(cw.common.path + '/json?action=GET_BACKUP_ACTION',{},function(data){
		if(data.success){
			if(data.root.FILE != null && data.root.FILE != undefined){
				var obj = data.root.FILE.rs[0];
				$('#filename').html(obj.filename);
				$('#filesize').html(obj.filesize);
				$('#date').html(obj.date);
				$('#backup').show();
//				$('#local').show();
			}
			else{
				$('#no_backup').show();
			}
		}
	},'json');
}


function backup(){
	if(confirm("如果已有备份数据将覆盖上次备份数据，是否继续？")){
		$.post(cw.common.path + '/json?action=DATA_BACKUP_ACTION',{},function(data){
		if(data.success){
			alert("数据备份成功");
			location.href = document.URL;
		}
		},'json');
	}
	
}